#ifndef GW_RELAYCONTROL_H
#define GW_RELAYCONTROL_H

#include "stm32f0xx.h"
#include "GWType.h"
#include "resource.h"
#include <vector>

#ifdef __cplusplus
extern "C"
{
#endif

#define  RELAYMODE_AUTO    0
#define  RELAYMODE_MANUAL  1
#define  RELAYMODE_PULSE   2
#define  RELAYMODE_MASK    3

class GW_RelayControl
{
private:
   u32   *mark;
   u8    time;
   u8    mode;
   u32   relay;
   bool  isAction;
   int   timeout;
   GPIO_PinState activeEdge;
   GPIO_TypeDef *CTLGPIO;
   uint16_t CTLPin;
public:
   //void read(u8 *buf, int length);
   GW_RelayControl();
   void  setCTLPin(GPIO_TypeDef *CTLGPIO, uint16_t CTLPin, GPIO_PinState activeEdge);
   void  resetTime();
   void  setTimeOut(int time);
   void  Tick(int second);
   void  enableRelay(int chid);
   void  disableRelay(int chid);
   void  setMark(u32 *mark);
   void  active();
   void  unactive();
   // ~GW_AdrDial();
};

extern   GW_RelayControl relayControl[3];

#ifdef __cplusplus
}
#endif
#endif
